home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 1.iso / dist / fw_teTeX.idb / usr / freeware / bin / texconfig.z / texconfig
Text File  |  2001-01-10  |  46KB  |  1,781 lines

  1. #!/bin/sh
  2.  
  3. test -f /bin/sh5 && test -z "$RUNNING_SH5" \
  4.   && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \
  5.   && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; }
  6. unset RUNNING_SH5
  7.  
  8. test -f /bin/bsh && test -z "$RUNNING_BSH" \
  9.   && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \
  10.   && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; }
  11. unset RUNNING_BSH
  12.  
  13. SAVE_ARGS=${1+"$@"}
  14.  
  15. version=teTeX
  16. #version='TeX Live'
  17.  
  18. case $version in
  19.   "TeX Live")
  20.     SILENT_TEXLINKS=true;;
  21. esac
  22.  
  23. # TeX-Config version 0.9 for teTeX and TeX Live. I hope, you will love
  24. # this script :-)
  25.  
  26. # More comments, more verbose messages, and better error handling are needed.
  27. # It sould give more help (e.g on ls-R and localfont) and ask a bit more
  28. # for confirmations.
  29.  
  30. # Any comments, improvements, ... please via Email to:
  31. # Thomas Esser, te@informatik.uni-hannover.de
  32. # Copyright: Thomas Esser, 1994, 1995, 1996, 1997, 1999. Public domain.
  33.  
  34. # You may override DIALOG_TERMINFO and DIALOG_TERM in your environment.
  35.  
  36. progname=`basename $0`
  37. tmpdir=${TMP-/tmp}/texconf$$
  38. tmpmenu=$tmpdir/menu.out
  39. tmpans=$tmpdir/answer.out
  40. std_pager=more
  41. xdvi_shrink_scale=75
  42. std_editor=vi
  43.  
  44. envvars="
  45. AFMFONTS BIBINPUTS BSTINPUTS DVILJFONTS DVIPSFONTS DVIPSHEADERS GFFONTS
  46. GLYPHFONTS INDEXSTYLE MFBASES MFINPUTS MFPOOL MFTINPUTS MPINPUTS MPMEMS
  47. MPPOOL MPSUPPORT OCPINPUTS OFMFONTS OPLFONTS OTPINPUTS OVFFONTS OVPFONTS
  48. PKFONTS PSHEADERS T1FONTS T1INPUTS TEXBIB TEXCONFIG TEXDOCS TEXFONTMAPS
  49. TEXFONTS TEXFORMATS TEXINDEXSTYLE TEXINPUTS TEXMFCNF TEXMFDBS TEXMFINI
  50. TEXPICTS TEXPKS TEXPOOL TEXPSHEADERS TEXSOURCES TFMFONTS TRFONTS VFFONTS
  51. XDVIFONTS XDVIVFS
  52. "
  53.  
  54. kpsevars='MetaPost support
  55. PostScript header
  56. TeX system documentation
  57. TeX system sources
  58. Troff fonts
  59. afm
  60. base
  61. bib
  62. bitmap font
  63. bst
  64. cnf
  65. dvips config
  66. fmt
  67. gf
  68. graphic/figure
  69. ist
  70. ls-R
  71. map
  72. mem
  73. mf
  74. mfpool
  75. mft
  76. mp
  77. mppool
  78. ocp
  79. ofm
  80. opl
  81. other text files
  82. otp
  83. ovf
  84. ovp
  85. pk
  86. tex
  87. texpool
  88. tfm
  89. truetype fonts
  90. type1 fonts
  91. type42 fonts
  92. vf
  93. web2c files'
  94.  
  95. umask 022
  96.  
  97. PATH=$PATH:`pwd`; export PATH
  98. log=$tmpdir/logfile
  99. unset mode || true
  100.  
  101. echo_a() { echo -n "$@"; }
  102. echo_b() { echo "$@\c"; }
  103. echo_c() { echo -e "$@\c"; }
  104. echo_d() { /bin/echo -n "$@"; }
  105. echo_e() { /bin/echo "$@\c"; }
  106. echo_f() { /bin/echo -e "$@\c"; }
  107.  
  108. find_echo()
  109. {
  110.   for i in a b c d e f; do
  111.     test "`echo_$i c``echo_$i a`"  = ca && echon=echo_$i && return
  112.   done
  113.   echon=echo
  114. }
  115.  
  116. find_fmt()
  117. {
  118.   FMT=fmt
  119.   test ! -x /bin/fmt && test ! -f /usr/bin/fmt &&
  120.     { test -x /bin/adjust || test -x /usr/bin/adjust; } && FMT=adjust
  121. }
  122.  
  123. cls() { test -z "$NO_CLEAR" && clear; }
  124.  
  125. # Some systems have their own dialog. Use it then and do not use
  126. # faked TERM and TERMINFO variables when calling that dialog.
  127. find_dialogtype()
  128. {
  129.   own_dialog=false
  130.   { u=`uname -s`; } 2>/dev/null
  131.   case "$u" in
  132.     FreeBSD|Linux)
  133.       DIALOG_PROG=/usr/bin/dialog
  134.       test -x "$DIALOG_PROG" && own_dialog=true;;
  135.   esac
  136. }
  137.  
  138. run_dialog()
  139. {
  140.   test -z "$NO_CLEAR" && clear
  141.   if $own_dialog; then
  142.     $DIALOG_PROG --title "$version setup utility" "$@"
  143.   else
  144.     TERM=$DIALOG_TERM TERMINFO=$DIALOG_TERMINFO dialog --title "$version setup utility" "$@"
  145.   fi
  146. }
  147.  
  148. check_environ()
  149. {
  150.   found=
  151.   for i in $envvars; do
  152.     eval var=\"\$$i\"
  153.     if [ ! -z "$var" ]; then
  154.       case $var in
  155.         :*|*:|*::*)    ;;
  156.         *)    found="$found $i"
  157.           ;;
  158.       esac
  159.     fi
  160.   done
  161.   test -z "$found" && return
  162.   clear
  163.   cat <<eof
  164. $progname has found the following environment variables set:
  165.  
  166. eof
  167.   for i in $found; do
  168.     eval echo \"    \$i = \$$i\"
  169.   done
  170.   cat <<eof
  171.  
  172. Please make sure, their values are ok, and otherwise change or unset them.
  173. If you continue with wrong values for the above variables, $progname
  174. might run into trouble when locating files on the disk.
  175.  
  176. Note that you can refer to the default path by giving an "empty" path
  177. component (i.e. a colon in front or in the end, or a doubled colon
  178. somewhere in the middle).
  179.  
  180. If you set TEXINPUTS, e.g. to :~/TeX/macros, (La)TeX will search along
  181. the default path and then in ~/TeX/macros.
  182.  
  183. For more information, see the Kpathsea and the teTeX manual.
  184.  
  185. eof
  186.   
  187.   $echon "Press RETURN to continue (or Control-C to abort)... "
  188.   read dummy
  189. }
  190.  
  191. fonts_ro()
  192. {
  193.   clear
  194.   echo "Removing global write permissions in fonts tree:" >&2
  195.   find $TC_TEXMFMAIN/fonts -perm -2 -type d -exec sh -c '
  196.     chmod -t $1 || exit;
  197.     chmod go-w $1 || exit;
  198.     echo $1 >&2;
  199.   ' sh '{}' \;
  200.   chmod go-w $TC_TEXMFMAIN/ls-R && echo $TC_TEXMFMAIN/ls-R >&2
  201.   echo "Done." >&2
  202. }
  203.  
  204. fonts_rw()
  205. {
  206.   clear
  207.   echo "Adding global write permissions in fonts tree:" >&2
  208.   find $TC_TEXMFMAIN/fonts/tfm $TC_TEXMFMAIN/fonts/pk $TC_TEXMFMAIN/fonts/source/jknappen $TC_TEXMFMAIN/fonts/source/lh $TC_TEXMFMAIN/fonts/source/public/cs \
  209.   -type d -exec sh -c '
  210.     case $1 in
  211.       */adobe*|*/bitstrea*)    exit;;
  212.     esac
  213.     chmod 1777 $1 || exit;
  214.     echo $1 >&2;
  215.   ' sh '{}' \;
  216.   chmod 1777 $TC_TEXMFMAIN/fonts || exit
  217.   echo $TC_TEXMFMAIN/fonts >&2
  218.   chmod 666 $TC_TEXMFMAIN/ls-R && echo $TC_TEXMFMAIN/ls-R >&2
  219.   echo "Done." >&2
  220. }
  221.  
  222. check_terminal()
  223. {
  224.   terminfo=${DIALOG_TERMINFO-/usr/lib/terminfo}
  225.  
  226.   test -f $terminfo/`echo $DIALOG_TERM | sed 's/\(.\).*/\1/'`/$DIALOG_TERM \
  227.     && return
  228.  
  229.   cat >&2 <<eof
  230. TERM=$DIALOG_TERM is not supported by your terminfo system.
  231. See terminfo(5), tic(1m) and term(5) for help.
  232.  
  233. $progname failed. Program aborted.
  234. eof
  235.   exit 1
  236. }
  237.  
  238. fix_pager_more()
  239. {
  240.   case "$PAGER" in
  241.     less*)    : ;;
  242.     *)    $echon 'Press return to continue... ' >&2
  243.         read foo;;
  244.   esac
  245. }
  246.  
  247. exist_test()
  248. {
  249.   type=$1 ; name=$2; what=$3
  250.   if [ ! "$type" "$name" ]; then
  251.     msg="Could not find $what."
  252.     if test -f $log; then
  253.       msg="$msg\\n\\nThe programm will show you the error-log and then exit."
  254.     else
  255.       msg="$msg\\n\\nThe programm will exit now."
  256.     fi
  257.     run_dialog --msgbox "$msg" 23 80
  258.     clear
  259.     if test -f $log; then
  260.       <$log eval $PAGER
  261.       fix_pager_more
  262.     fi
  263.     exit 1
  264.   fi
  265. }
  266.  
  267. choose_editor()
  268. {
  269.   run_dialog --inputbox \
  270.     "Your editor for changing config-files currently\\nis set to $EDIT.\\n\\nPress RETURN to accept this default or enter\\nthe name of the editor of your choice.\\n\\n" \
  271.     23 80 2>$tmpmenu || return
  272.   x=`cat $tmpmenu`
  273.   test -z "$x" || EDIT=$x
  274. }
  275.  
  276. choose_pager()
  277. {
  278.   run_dialog --inputbox \
  279.     "Your pager to view the logfile currently\\nis set to $PAGER.\\n\\nPress RETURN to accept this default or enter\\nthe name of the pager of your choice.\\n\\n" \
  280.     23 80 2>$tmpmenu || return
  281.   x=`cat $tmpmenu`
  282.   test -z "$x" || PAGER=$x
  283. }
  284.  
  285.  
  286. setup_preferences()
  287. {
  288.   while true ; do
  289.     run_dialog \
  290.       --menu "\\n\\nSet up your editor and pager for this texconfig session.\\n\\n" \
  291.       23 80 4 \
  292.       RETURN 'back to main menu' \
  293.       EDITOR 'set up editor for changing config-files' \
  294.       PAGER 'set up pager to view the logfile' \
  295.       LOG 'view logfile' \
  296.       2>$tmpmenu || return
  297.     ans=`cat $tmpmenu`
  298.     test -z "$ans" && return
  299.     case "$ans" in
  300.       EDITOR)       choose_editor ;;
  301.       PAGER)      choose_pager ;;
  302.       LOG)    clear; <$log eval $PAGER; fix_pager_more ;;
  303.       RETURN)     return ;;
  304.     esac
  305.   done
  306. }
  307.  
  308. config_tex()
  309. {
  310.   exist_test -d "$formats" "directory for format files"
  311.  
  312.   clear
  313.   edit_hyphen
  314. }
  315.  
  316. choose_mode()
  317. {
  318.   out=$1
  319.   choose_mode_msg="$2"
  320.   mode=$default_mode
  321.   exist_test -f "$modes" "modes.mf file"
  322.   if [ ! -z "$mode" ] ; then
  323.     if yesno "\\n\\nUse mode $mode as default $3?\\n\\n" 23 80 ; then
  324.       : # nothing
  325.     else
  326.       mode=""
  327.     fi
  328.   fi
  329.   if [ -z "$mode" ] ; then
  330.     #--title \"teTeX-Config: MetaFont mode\" \
  331.       eval run_dialog \
  332.     --menu \"\$choose_mode_msg\" \
  333.     23 80 14 `list_mf_modes $modes` \
  334.     2>$out
  335.   else
  336.     echo $mode >$out
  337.   fi
  338. }
  339.  
  340. get_default_mode()
  341. {
  342.   choose_mode $tmpans 'Choose a default mode for xdvi, dvips and metafont. As a rule\nof thumb, choose the most commonly mode used for printing at your site.'
  343.   default_mode=`cat $tmpans`
  344.   test -z "$default_mode" && return
  345.  
  346.   clear
  347.   do_set_default_mode "$default_mode" 2>&1 | tee -a $log
  348.  
  349. }
  350.  
  351. do_set_default_mode()
  352. {
  353.   mode=$1
  354.   set x `find_res $mode`; shift
  355.   res_x=$1; res_y=$2
  356.   dvips_conf=$dvips_conf_dir/config.ps
  357.  
  358.   run_setup_mf_mode "$mode"
  359.   run_dvips_setup_mode "$mode" "$res_x" "$res_y"
  360.   run_xdvi_setup_mode "$mode" "$res_x"
  361.   config_replace "$maketex_site_file" '^: ..MODE' ": \${MODE=$mode}"
  362.   config_replace "$maketex_site_file" '^: ..BDPI' ": \${BDPI=$res_x}"
  363.  
  364.   run_config_mf
  365.  
  366. }
  367.  
  368. run_config_mf()
  369. {
  370.   test -d "$TC_TEXMFMAIN/metafont" || return
  371.  
  372.   exist_test -d "$bases" "directory for base files"
  373.   exist_test -f "$modes" "modes.mf file"
  374.  
  375.   echo "Running mf to create plain base ..."
  376.   run_create_mf_base
  377.   echo "Done."; echo
  378. }
  379.  
  380. run_setup_mf_mode()
  381. {
  382.   mode="$1"
  383.   ed $modes >/dev/null 2>&1 <<eof
  384. /^localfont :=/
  385. c
  386. localfont := $mode;
  387. .
  388. w
  389. q
  390. eof
  391. }
  392.  
  393. run_create_mf_base()
  394. {
  395.   rm -f *.log *.base
  396.   mf -ini mf.mf </dev/null || return
  397.   for i in *.log *.base; do rm -f "$bases/$i"; \mv "$i" "$bases/$i"; done
  398.   rm -f $bases/plain.base $bases/mfw.base
  399.   ln -s mf.base $bases/plain.base
  400.   ln -s mf.base $bases/mfw.base
  401.   $TC_MKTEXUPD $bases mf.base 2>/dev/null
  402.   $TC_MKTEXUPD $bases mfw.base 2>/dev/null
  403.   $TC_MKTEXUPD $bases plain.base 2>/dev/null
  404. }
  405.  
  406. run_config_mp()
  407. {
  408.   test -d "$TC_TEXMFMAIN/metapost" || return
  409.  
  410.   exist_test -d "$mems" "directory for mem files"
  411.  
  412.   echo "Running mpost to create plain mem ..."
  413.   run_create_mp_mem
  414.   echo "Done."; echo
  415. }
  416.  
  417. run_create_mp_mem()
  418. {
  419.   rm -f *.log *.mem
  420.   mpost -ini mpost.mp </dev/null || return
  421.   for i in *.log *.mem; do rm -f "$mems/$i"; \mv "$i" "$mems/$i"; done
  422.   rm -f $mems/plain.mem
  423.   ln -s mpost.mem $mems/plain.mem
  424.   $TC_MKTEXUPD $mems plain.mem
  425.   $TC_MKTEXUPD $mems mpost.mem
  426. }
  427.  
  428. select_format()
  429. {
  430.   a=`list_formats`
  431.  
  432.   test -z "$a" && {
  433.     run_dialog --msgbox \
  434.       "No format which allows setting hyphenation." 23 80
  435.     formatname=
  436.     return
  437.   }
  438.  
  439.   eval run_dialog \
  440.     --menu \'\\n\\nChoose format to set up hyphenation for.\\n\\n\' \
  441.     23 80 8 $a \
  442.     2>$tmpmenu || return
  443.   formatname=`cat $tmpmenu`
  444. }
  445.  
  446. config_dvips_paper()
  447. {
  448.   eval run_dialog \
  449.     --menu \'\\n\\nChoose the default papersize definition for dvips.\\n\\n\' \
  450.     23 80 8 `list_dvips_papers $dvips_conf` \
  451.     2>$tmpmenu || return
  452.   paper=`cat $tmpmenu`
  453.   test -z "$paper" && return ;
  454.   setup_dvips_paper "$paper" 2>&1 | tee -a $log
  455. }
  456.  
  457. dvips_choose_printcmd()
  458. {
  459.   run_dialog --inputbox \
  460.     "\\n\\nEnter the command to print to the printer '$printer'.\\nIn general, you need a command like 'lpr' or 'lpr -Pfoo'.\\n\\nNOTE: If you just press return, printing will be disabled\\nand the output saved to a file by default.\\n\\n" \
  461.     23 80 2>$tmpmenu || return
  462.   x=`cat $tmpmenu`
  463.   if [ -z "$x" ] ; then
  464.     echo save-to-file >&2
  465.   else
  466.     echo $x >&2
  467.   fi
  468.  
  469. }
  470.  
  471. has_latex()
  472. {
  473.   test -d $TC_TEXMFMAIN/tex/latex && return 0
  474.   run_dialog --msgbox \
  475.     "This funtion needs LaTeX to be installed." 23 80
  476.   return 1
  477. }
  478.  
  479. dvips_test_print()
  480. {
  481.   has_latex || return
  482.   cd $tmpdir          
  483.   clear
  484.   latex testpage          2>&1 | tee -a $log
  485.   case $printer in
  486.       default)    dvips testpage ;;
  487.       *)    dvips -P$printer testpage ;;
  488.   esac 2>&1 | tee -a $log
  489.   
  490. }
  491.  
  492. yesno() { run_dialog --yesno "$@"; }
  493.  
  494. dvips_setup_mode()
  495. {
  496.   choose_mode $tmpans "Choose the metafont mode for printer '$printer'" "for printer $printer"
  497.   mode=`cat $tmpans`
  498.   test -z "$mode" && return
  499.   run_dvips_setup_mode "$mode" 2>&1 | tee -a $log
  500. }
  501.  
  502. run_dvips_setup_mode()
  503. {
  504.   mode="$1"
  505.   if test -z "$2"; then
  506.     set x `find_res $mode`; shift
  507.     res_x=$1; res_y=$2
  508.   else
  509.     res_x=$2
  510.     res_y=${3-$2}
  511.   fi
  512.   config_replace "$dvips_conf" '^M' "M $mode"
  513.   config_replace "$dvips_conf" '^D' "D $res_x"
  514.   config_replace "$dvips_conf" '^X' "X $res_x"
  515.   config_replace "$dvips_conf" '^Y' "Y $res_y"
  516. }
  517.  
  518. dvips_setup_printcmd()
  519. {
  520.   dvips_choose_printcmd 2>$tmpans
  521.   printcmd=`cat $tmpans`
  522.   test -z "$printcmd" && return
  523.   do_dvips_setup_printcmd "$printcmd" 2>&1 | tee -a $log
  524. }
  525.  
  526. do_dvips_setup_printcmd()
  527. {
  528.   printcmd="$@"
  529.   if test "$printcmd" = save-to-file; then
  530.     config_replace "$dvips_conf" '^o' 'o'
  531.   else
  532.     config_replace "$dvips_conf" '^o' "o |$printcmd"
  533.   fi
  534. }
  535.  
  536. dvips_setup_offset()
  537. {
  538.   run_dialog --inputbox \
  539.     "
  540.  
  541. Enter a dimension pair (A rightwards offset and a downwards
  542. offset), e.g. 2mm,-0.5in (right 2mm and up .5in):
  543.  
  544. " \
  545.     23 80 2>$tmpmenu || return
  546.   x=`cat $tmpmenu`
  547.   test -z "$x" || run_dvips_setup_offset "$x" 2>&1 | tee -a $log
  548. }
  549.  
  550. do_dvips_setup_offset()
  551. {
  552.   x="$1"
  553.   if test -z "$x"; then
  554.     echo "Error: no offset given to do_dvips_setup_offset. Skipped." >&2
  555.     return
  556.   fi
  557.   run_dvips_setup_offset "$x"
  558. }
  559.  
  560. run_dvips_setup_offset()
  561. {
  562.   x="$1"
  563.   config_replace "$dvips_conf" '^O' "O $x"
  564. }
  565.  
  566. dvips_config_local()
  567. {
  568.   exist_test -d "$dvips_conf_dir" "config file for dvips (config.ps)"
  569.  
  570.   while true ; do
  571.     run_dialog \
  572.       --menu "\\n\\n$version: set up printer '$printer' for dvips\\n\\n" \
  573.       23 80 5 \
  574.       RETURN 'Back to dvips main menu' \
  575.       MODE 'Set up mf mode (resolution will be calculated as well)' \
  576.       CMD 'Set up the command to print on this printer' \
  577.       OFFSETS 'Set up offsets for printing' \
  578.       TEST 'Print a testpage' \
  579.       2>$tmpmenu || return
  580.     ans=`cat $tmpmenu`
  581.     test -z "$ans" && return
  582.     case "$ans" in
  583.       MODE)    dvips_setup_mode ;;
  584.       CMD)    dvips_setup_printcmd ;;
  585.       OFFSETS)    dvips_setup_offset ;;
  586.       TEST)    dvips_test_print ;;
  587.       RETURN)    return ;;
  588.     esac
  589.   done
  590. }
  591.  
  592. dvips_config_global()
  593. {
  594.   config_dvips_paper
  595.   printer=default
  596.   dvips_config_local
  597. }
  598.  
  599. dvips_get_printername()
  600. {
  601.   run_dialog --inputbox \
  602.     "Printer name" \
  603.     23 80 2>$tmpmenu || return
  604.   x=`cat $tmpmenu`
  605.   test -z "$x" || echo $x >&2
  606. }
  607.  
  608. config_dvips()
  609. {
  610.   while true; do
  611.     run_dialog \
  612.       --menu '
  613. dvips section: If you only have no more than one printer, you
  614. only need to go through the GLOBAL menu. You can use dvips for non
  615. PostScript printers, if you can setup your printing system to convert
  616. PostScript to a format that your printer can handle. Maybe, you can
  617. use GhostScript to do the conversation (if you printer is supported).
  618.  
  619. A definition for a printer PRINTER directly corresponds to a
  620. configuration file config.PRINTER in the $TC_VARTEXMF/dvips directory.
  621.  
  622. ' \
  623.       23 80 6 \
  624.       RETURN 'back to main menu' \
  625.       GLOBAL 'global settings' \
  626.       ADD 'add a printer configuration (to be used via -P flag)' \
  627.       DEL 'remove a printer definition' \
  628.       CHANGE 'change an existing printer definition' \
  629.       "LOG"    'view logfile' \
  630.       2>$tmpmenu || return
  631.     ans=`cat $tmpmenu`
  632.     test -z "$ans" && return
  633.     case "$ans" in
  634.       ADD|DEL|CHANGE)
  635.         dvips_get_printername 2>$tmpans
  636.         printer=`cat $tmpans`
  637.         test -z "$printer" && continue
  638.         dvips_conf=$dvips_conf_dir/config.$printer
  639.         ;;
  640.     esac
  641.     case "$ans" in
  642.       GLOBAL)     dvips_conf=$dvips_conf_dir/config.ps
  643.       dvips_config_global ;;
  644.       ADD)    if [ -f $dvips_conf_dir/config.$printer ] ; then
  645.         run_dialog --msgbox \
  646.           "Configuration for $printer already exists." 23 80
  647.         continue
  648.       fi
  649.       touch $dvips_conf_dir/config.$printer
  650.       $TC_MKTEXUPD $dvips_conf_dir config.$printer
  651.       dvips_config_local ;;
  652.       DEL)    rm -f $dvips_conf_dir/config.$printer $dvips_conf_dir/config.$printer.orig ;;
  653.       CHANGE)    if [ ! -f $dvips_conf_dir/config.$printer ] ; then
  654.         run_dialog --msgbox \
  655.           "Configuration for $printer not found." 23 80
  656.         continue
  657.       fi
  658.       dvips_config_local ;;
  659.       LOG)    clear; <$log eval $PAGER; fix_pager_more;;
  660.       RETURN)    return ;;
  661.     esac
  662.   done
  663. }
  664.  
  665. do_dvips_setup_paper()
  666. {
  667.   paper="$1"
  668.   list=`list_dvips_papers $dvips_conf | awk '{print $1}'`
  669.   if test_in_list "$paper" $list; then
  670.     setup_dvips_paper "$paper"
  671.   fi
  672. }
  673.  
  674. do_xdvi_setup_paper()
  675. {
  676.   paper="$1"
  677.   list=`list_xdvi_papers | awk '{print $1}'`
  678.   if test_in_list "$paper" $list; then
  679.     run_xdvi_setup_paper "$paper"
  680.   fi
  681. }
  682.  
  683. run_xdvi_setup_paper()
  684. {
  685.   paper="$1"
  686.   config_replace "$xdvi_app_file" 'paper:' "XDvi*paper: $paper"
  687. }
  688.  
  689. xdvi_setup_paper()
  690. {
  691.   #--title \"TeX-Config: xdvi default paper\" \
  692.   eval run_dialog \
  693.     --menu \"Choose the default papersize definition for xdvi.\" \
  694.     23 80 15 `list_xdvi_papers` \
  695.     2>$tmpmenu || return
  696.   paper=`cat $tmpmenu`
  697.   test -z "$paper" && return
  698.   run_xdvi_setup_paper "$paper" 2>&1 | tee -a $log
  699. }
  700.  
  701. do_dvips_setup_mode()
  702. {
  703.   mode="$1"
  704.   if test -z "$mode"; then
  705.     echo "Error: no mode given to do_dvips_setup_mode. Skipped.">&2
  706.     return 1
  707.   fi
  708.   list=`list_mf_modes $modes | awk '{print $1}'`
  709.   if test_in_list "$mode" $list; then
  710.     run_dvips_setup_mode "$mode"
  711.   fi
  712. }
  713.  
  714. cmd_mode_maketex()
  715. {
  716.   case "$1" in
  717.     vardir)
  718.       if test -z "$2"; then
  719.         echo "Usage: texconfig font vardir DIR" >&2
  720.         return 1
  721.       else
  722.         do_setup_mt_vardir "$2"
  723.       fi
  724.       ;;
  725.     ro)
  726.       fonts_ro;;
  727.     rw)
  728.       fonts_rw;;
  729.     options)
  730.       shift
  731.       if test $# = 0; then
  732.         echo "Usage: texconfig options OPTIONS ..." >&2
  733.         return 1
  734.       fi
  735.       if test "$*" = -; then
  736.         set_mt_options
  737.       else
  738.         set_mt_options "$@"
  739.       fi
  740.       ;;
  741.     *)
  742.       echo "Usage: texconfig font vardir DIR" >&2
  743.       echo "       texconfig font ro" >&2
  744.       echo "       texconfig font rw" >&2
  745.       echo "       texconfig font options OPTIONS ..." >&2
  746.       echo >&2
  747.       echo "       valid OPTIONS: $all_mt_features -" >&2
  748.       echo "       the special OPTION '-' can be used to disable all OPTIONS" >&2
  749.       return 1
  750.       ;;
  751.   esac
  752. }
  753.  
  754. cmd_mode_set_default_mode()
  755. {
  756.   mode="$1"
  757.   case "$mode" in
  758.     "") echo "Usage: texconfig mode MODE" >&2
  759.         echo "       Valid modes:" >&2
  760.         echo >&2
  761.         list_mf_modes $modes | awk '{print $1}' | $FMT >&2
  762.         echo >&2
  763.         echo "See file $modes" >&2
  764.         echo "for more information about these modes." >&2
  765.         return 1;;
  766.   esac
  767.   list=`list_mf_modes $modes | awk '{print $1}'`
  768.   if test_in_list "$mode" $list; then
  769.     do_set_default_mode "$mode"
  770.   fi
  771. }
  772.  
  773. run_xdvi_setup_mode()
  774. {
  775.   mode="$1"
  776.   res=${2-`find_res $mode 2>>$log | awk '{ print $1 }'`}
  777.   shrink=`expr $res / $xdvi_shrink_scale`
  778.   if test $res -lt 300; then
  779.     b1=1; b2=2; b3=3; b4=4
  780.   else
  781.     b1=`expr 1 \* $res / 300`
  782.     b2=`expr 2 \* $res / 300`
  783.     b3=`expr 3 \* $res / 300`
  784.     b4=`expr 4 \* $res / 300`
  785.   fi
  786.   config_replace "$xdvi_app_file" 'mfMode:' "XDvi*mfMode: $mode"                    2>&1 | tee -a $log
  787.   config_replace "$xdvi_app_file" 'pixelsPerInch:' "XDvi*pixelsPerInch: $res"       2>&1 | tee -a $log
  788.   config_replace "$xdvi_app_file" 'shrinkFactor:' "XDvi*shrinkFactor: $shrink"      2>&1 | tee -a $log
  789.   config_replace "$xdvi_app_file" 'shrinkButton1:' "XDvi*shrinkButton1: $b1"      2>&1 | tee -a $log
  790.   config_replace "$xdvi_app_file" 'shrinkButton2:' "XDvi*shrinkButton2: $b2"      2>&1 | tee -a $log
  791.   config_replace "$xdvi_app_file" 'shrinkButton3:' "XDvi*shrinkButton3: $b3"      2>&1 | tee -a $log
  792.   config_replace "$xdvi_app_file" 'shrinkButton4:' "XDvi*shrinkButton4: $b4"      2>&1 | tee -a $log
  793. }
  794.  
  795. xdvi_make_test()
  796. {
  797.   if [ -z "$DISPLAY" ] ; then
  798.     :
  799.   fi
  800.   cd $tmpdir 2>&1 | tee -a $log
  801.   clear
  802.   tex '\input story\end' 2>&1 | tee -a $log
  803.   clear
  804.   xdvi story 2>&1 | tee -a $log
  805. }
  806.  
  807.  
  808. config_xdvi()
  809. {
  810.   test -d "$xdvi_app_dir" || $TC_MKTEXDIR "$xdvi_app_dir"
  811.   test -f "$xdvi_app_file" || touch "$xdvi_app_file"
  812.   exist_test -f "$xdvi_app_file" "app-default file for xdvi"
  813.  
  814.   while true ; do
  815.     run_dialog \
  816.       --menu '\n\nSet up xdvi via application ressources.\n\nNote 1: set the mode from the main menu.\nNote 2: a symbolic Link for the app-default file is no longer necessary.\n\n' \
  817.       23 80 4 \
  818.       RETURN 'back to main menu' \
  819.       PAPER 'default papertype' \
  820.       TEST 'view a testfile' \
  821.       LOG 'view logfile' \
  822.       2>$tmpmenu || return
  823.     ans=`cat $tmpmenu`
  824.     test -z "$ans" && return
  825.     case "$ans" in
  826.       PAPER)        xdvi_setup_paper ;;
  827.       TEST)       xdvi_make_test ;;
  828.       LOG)    clear; <$log eval $PAGER; fix_pager_more;;
  829.       RETURN)     return ;;
  830.     esac
  831.   done
  832. }
  833.  
  834. keep_mode() { yesno "\\n\\nUse mode $mode\\n\\n" 23 80; }
  835.  
  836. config_replace()
  837. {
  838.   config=$1
  839.   pattern=$2
  840.   replacement=$3
  841.  
  842.   require_binary ed
  843.  
  844.   test -f "$config" > /dev/null 2>&1
  845.   if [ $? != 0 ]; then
  846.     echo "config_replace: file '$config' not found." >&2
  847.     return
  848.   fi
  849.  
  850.   test -w "$config" > /dev/null 2>&1
  851.   if [ $? != 0 ]; then
  852.     echo "config_replace: cannot write to file '$config'." >&2
  853.     return
  854.   fi
  855.  
  856.   egrep -e "$pattern" "$config" > /dev/null 2>&1 
  857.   if [ $? != 0 ]; then
  858.     echo "$replacement" >> "$config"
  859.   else
  860.     ed $config >/dev/null 2>&1 <<eof
  861. /$pattern/c
  862. $replacement
  863. .
  864. w
  865. q
  866. eof
  867.     error=$?
  868.     if [ $error != 0 ]; then
  869.       echo "config_replace: ed returned error code '$error'." >&2
  870.       return
  871.     fi
  872.   fi
  873. }
  874.  
  875. find_res()
  876. {
  877.   cat >mftmp.mf <<'eof'
  878. let myexit = primitive_end_;
  879. mode_setup;
  880. string xdpi;
  881. xdpi := decimal round pixels_per_inch;
  882. message "XDPI = " & xdpi;
  883. string ydpi;
  884. ydpi := decimal round (pixels_per_inch * aspect_ratio);
  885. message "YDPI = " & ydpi;
  886. fontmaking := 0;
  887. myexit;
  888. eof
  889.   mf '\mode='"$1"';  \input ./mftmp' </dev/null | awk '$1 == "XDPI" || $1 == "YDPI" { print $3 }'
  890. }
  891.  
  892. mode_name()
  893. {
  894.   mf '\mode='"$1"';  \input modename' | sed -n '/^MODENAME/!d; s/.*= //; s/_.*//; p'
  895. }
  896.  
  897. list_formats()
  898. {
  899.   exist_test -f "$fmtutilcnf" "fmtutil.cnf file"
  900.  
  901.   awk '$3 != "-"' "$fmtutilcnf" |
  902.   sed 's@[%#].*@@; s@^[     ]*@@; /^$/d' \
  903.     | awk '{print $1}' | sed "s@.*@'&' '&'@" | sort
  904. }
  905.  
  906. list_dvips_papers()
  907. {
  908.   grep '@ ' $1 | sed "s/..//;s/ / '/;s/\$/' /"
  909. }
  910.  
  911. list_mf_modes()
  912. {
  913.   grep mode_def $1 |
  914.   sed -e "s/mode_def //" \
  915.       -e "s/ .*%[^ ]* / '/" \
  916.       -e "s/\$/' /" |
  917.   egrep -v "^(help|%)" | sort
  918. }
  919.  
  920. list_xdvi_papers()
  921. {
  922.   cat <<'eof'
  923. us           "8.5x11"
  924. usr          "11x8.5"
  925. legal        "8.5x14"
  926. foolscap     "13.5x17.0"
  927. a1           "59.4x84.0cm"
  928. a2           "42.0x59.4cm"
  929. a3           "29.7x42.0cm"
  930. a4           "21.0x29.7cm"
  931. a5           "14.85x21.0cm"
  932. a6           "10.5x14.85cm"
  933. a7           "7.42x10.5cm"
  934. a1r          "84.0x59.4cm"
  935. a2r          "59.4x42.0cm"
  936. a3r          "42.0x29.7cm"
  937. a4r          "29.7x21.0cm"
  938. a5r          "21.0x14.85cm"
  939. a6r          "14.85x10.5cm"
  940. a7r          "10.5x7.42cm"
  941. b1           "70.6x100.0cm"
  942. b2           "50.0x70.6cm"
  943. b3           "35.3x50.0cm"
  944. b4           "25.0x35.3cm"
  945. b5           "17.6x25.0cm"
  946. b6           "13.5x17.6cm"
  947. b7           "8.8x13.5cm"
  948. b1r          "100.0x70.6cm"
  949. b2r          "70.6x50.0cm"
  950. b3r          "50.0x35.3cm"
  951. b4r          "35.3x25.0cm"
  952. b5r          "25.0x17.6cm"
  953. b6r          "17.6x13.5cm"
  954. b7r          "13.5x8.8cm"
  955. c1           "64.8x91.6cm"
  956. c2           "45.8x64.8cm"
  957. c3           "32.4x45.8cm"
  958. c4           "22.9x32.4cm"
  959. c5           "16.2x22.9cm"
  960. c6           "11.46x16.2cm"
  961. c7           "8.1x11.46cm"
  962. c1r          "91.6x64.8cm"
  963. c2r          "64.8x45.8cm"
  964. c3r          "45.8x32.4cm"
  965. c4r          "32.4x22.9cm"
  966. c5r          "22.9x16.2cm"
  967. c6r          "16.2x11.46cm"
  968. c7r          "11.46x8.1cm"
  969. eof
  970. }
  971.  
  972. setup_dvips_paper()
  973. {
  974.   config=$dvips_conf
  975.   paper=$1
  976.  
  977.   test -f "$config" > /dev/null 2>&1
  978.   if [ $? != 0 ]; then
  979.     echo "setup_dvips_paper: global dvips config file '$config' not found." >&2
  980.     return
  981.   fi
  982.  
  983.   test -w "$config" > /dev/null 2>&1
  984.   if [ $? != 0 ]; then
  985.     echo "setup_dvips_paper: cannot write to file '$config'." >&2
  986.     return
  987.   fi
  988.  
  989.   grep "@ $paper" "$config" > /dev/null 2>&1 
  990.   if [ $? != 0 ]; then
  991.     echo "setup_dvips_paper: paper '$paper' not found in file '$config'." >&2
  992.     return
  993.   fi
  994.  
  995.   ed $config > /dev/null 2>&1 <<eof
  996. /@ /ka
  997. \$a
  998. .
  999. /@ $paper/;/@ /-1m'a-1
  1000. \$d
  1001. w
  1002. q
  1003. eof
  1004.  
  1005.   error=$?
  1006.  
  1007.   if [ $error != 0 ]; then
  1008.     echo "setup_dvips_paper: ed returned error code '$error'." >&2
  1009.   fi
  1010. }
  1011.  
  1012. cmd_mode()
  1013. {
  1014.   case "$1" in
  1015.     faq)    clear; test -f $FAQ && <$FAQ eval $PAGER; fix_pager_more;;
  1016.     conf)    do_print_setup;;
  1017.     formats)    config_formats;;
  1018.     hyphen)    shift; do_edit_hyphen ${1+"$@"} ;;
  1019.     mode)    shift; cmd_mode_set_default_mode ${1+"$@"} ;;
  1020.     xdvi)    shift; cmd_mode_xdvi ${1+"$@"};;
  1021.     dvips)    shift; cmd_mode_dvips ${1+"$@"};;
  1022.     font) shift; cmd_mode_maketex ${1+"$@"};;
  1023.     confall) do_print_all_setup;;
  1024.     init)    init_all;;
  1025.     *)    echo "Usage: texconfig conf" >&2
  1026.       echo "       texconfig confall" >&2
  1027.       echo "       texconfig rehash" >&2
  1028.       echo "       texconfig formats" >&2
  1029.       echo "       texconfig hyphen FORMAT" >&2
  1030.       echo "       texconfig mode    [options]" >&2
  1031.       echo "       texconfig xdvi    [options] ..." >&2
  1032.       echo "       texconfig dvips   [options] ..." >&2
  1033.       echo "       texconfig font    [options] ..." >&2
  1034.       echo "       texconfig faq" >&2
  1035.       echo "       texconfig init" >&2
  1036.       echo >&2
  1037.       echo "Get help with:" >&2
  1038.       echo "       texconfig help" >&2
  1039.       echo "       texconfig hyphen" >&2
  1040.       echo "       texconfig mode" >&2
  1041.       echo "       texconfig xdvi" >&2
  1042.       echo "       texconfig dvips" >&2
  1043.       echo "       texconfig font" >&2
  1044.       exit 1;;
  1045.   esac
  1046.   exit
  1047. }
  1048.  
  1049. cmd_mode_dvips()
  1050. {
  1051.   printer=""
  1052.   dvips_conf="$dvips_conf_dir/config.ps"
  1053.   case "$1" in
  1054.     -P)    printer=$2; shift; shift;;
  1055.     -P*)    printer=`echo $2 | sed 's/..//'`; shift;;
  1056.   esac
  1057.   test -z "$printer" || dvips_conf="$dvips_conf_dir/config.$printer"
  1058.   case "$1" in
  1059.     add)    if test -z "$2"; then
  1060.         echo "Usage: texconfig dvips add PRINTER" >&2
  1061.       else
  1062.         touch "$dvips_conf_dir/config.$2"
  1063.         $TC_MKTEXUPD "$dvips_conf_dir" "config.$2"
  1064.       fi;;
  1065.     del)    if test -z "$2"; then
  1066.         echo "Usage: texconfig dvips del PRINTER" >&2
  1067.       else
  1068.         rm -f "$dvips_conf_dir/config.$2"
  1069.       fi;;
  1070.     mode)
  1071.       if test -z "$2"; then
  1072.         echo "Usage: texconfig dvips [-P PRINTER] mode MODE" >&2
  1073.         echo "       Valid modes:" >&2                                 
  1074.         echo >&2
  1075.         list_mf_modes $modes | awk '{print $1}' | $FMT >&2       
  1076.         echo >&2
  1077.         echo "See file $modes" >&2                 
  1078.         echo "for more information about these modes." >&2
  1079.       else
  1080.         do_dvips_setup_mode "$2"
  1081.       fi;;
  1082.  
  1083.     printcmd)
  1084.       case "$2" in
  1085.         "")    echo "Usage: dvips [-P PRINTER] printcmd CMD" >&2
  1086.           echo "       For printing, the output will be piped to the CMD" >&2
  1087.           echo "       Typically, CMD is set to 'lpr' or 'lpr -P SOME-NAME'." >&2
  1088.           echo >&2
  1089.           echo "       Use - as CMD to disable direct drinting." >&2;;
  1090.         -)    do_dvips_setup_printcmd save-to-file;;
  1091.         *)    shift; do_dvips_setup_printcmd ${1+"$@"};;
  1092.       esac;;
  1093.     offset)    if test -z "$2"; then
  1094.         echo "Usage: dvips [-P PRINTER] offset OFFSET" >&2
  1095.         echo "       For OFFSET choose a dimension pair, such as '0.4in,-2in'." >&2
  1096.       else
  1097.         do_dvips_setup_offset "$2"
  1098.       fi;;
  1099.     paper)
  1100.       if test -z "$2"; then
  1101.         echo "Usage: texconfig dvips paper PAPER" >&2
  1102.         echo "       Valid papertypes:" >&2
  1103.         echo >&2
  1104.         list_dvips_papers $dvips_conf | awk '{print $1}' | $FMT >&2
  1105.       else
  1106.         dvips_conf="$dvips_conf_dir/config.ps"
  1107.         do_dvips_setup_paper "$2"
  1108.       fi;;
  1109.     *)    cat<<'eof'
  1110. Usage: texconfig dvips add PRINTER
  1111.        texconfig dvips del PRINTER
  1112.        texconfig dvips paper PAPER
  1113.        texconfig dvips [-P PRINTER] mode MODE
  1114.        texconfig dvips [-P PRINTER] offset OFFSET
  1115.        texconfig dvips [-P PRINTER] printcmd CMD
  1116. eof
  1117.   esac
  1118. }
  1119.  
  1120. cmd_mode_xdvi()
  1121. {
  1122.   case $# in
  1123.     1)    do_xdvi_setup_paper "$1";;
  1124.     *)    { echo 'Usage: texconfig xdvi PAPER'
  1125.     echo "       recognised papersizes are:"; echo
  1126.     echo "`list_xdvi_papers | awk '{print $1}' | $FMT`"; } >&2
  1127.   esac
  1128. }
  1129.  
  1130. test_in_list()
  1131. {
  1132.   obj="$1"; shift
  1133.   test -z "$obj" && return 1
  1134.   for i
  1135.   do
  1136.     test "$obj" = "$i" && return 0
  1137.   done
  1138.   echo "Error: value '$obj' not in list '$@'." >&2
  1139.   return 1
  1140. }
  1141.   
  1142.  
  1143. init_tex_formats()
  1144. {
  1145.   fmtutil --all
  1146.   texlinks ${SILENT_TEXLINKS+-s}
  1147. }
  1148.  
  1149. init_all()
  1150. {
  1151.   init_tex_formats
  1152.   run_config_mf
  1153.   check_for_binary mpost >/dev/null && run_config_mp
  1154. }
  1155.  
  1156.  
  1157. edit_hyphen()
  1158. {
  1159.   select_format
  1160.   clear
  1161.   test -z "$formatname" && return
  1162.  
  1163.   do_edit_hyphen "$formatname"
  1164. }
  1165.  
  1166. do_edit_hyphen()
  1167. {
  1168.   formatname="$1"     
  1169.   test -n "$formatname" \
  1170.     && language=`fmtutil --showhyphen "$formatname"`
  1171.   case "${formatname}%${language}" in
  1172.     %*|*%)
  1173.         echo "Usage: texconfig hyphen FORMAT" >&2
  1174.         echo "       Valid formats:" >&2
  1175.         echo >&2
  1176.         list_formats | sed "s@.@@; s@'.*@@" | fmt >&2
  1177.         return 1;; 
  1178.   esac
  1179.  
  1180.   tmpfile=hy$$
  1181.   sed 's@[%].*@@; s@^[     ]*@@; /^$/d' $language | sort > $tmpfile-1
  1182.   $EDIT $language
  1183.   sed 's@[%].*@@; s@^[     ]*@@; /^$/d' $language | sort > $tmpfile-2
  1184.  
  1185.   cmp $tmpfile-1 $tmpfile-2 >/dev/null 2>&1 && return
  1186.   fmtutil --byhyphen $language 2>&1 | tee -a $log
  1187. }
  1188.  
  1189. check_for_binary()
  1190. {
  1191.   testbin=$1
  1192.   set x `echo "$PATH" | sed 's/^:/.:/; s/:$/:./; s/::/:.:/g; s/:/ /g'`; shift
  1193.   for i
  1194.   do
  1195.     if [ -x "$i/$testbin" ]; then
  1196.       echo "$i/$testbin"
  1197.       return 0
  1198.     fi
  1199.   done
  1200.   return 1
  1201. }
  1202.  
  1203. require_binary()
  1204. {
  1205.   for this_binary
  1206.   do
  1207.     check_for_binary $this_binary >/dev/null
  1208.     if [ $? != 0 ]; then
  1209.       echo "texconfig: binary $this_binary not found. Please set up your PATH correctly" >&2
  1210.       exit 1
  1211.     fi
  1212.   done
  1213. }
  1214.  
  1215. echo_locate_binary()
  1216. {
  1217.   for locate_this_bin
  1218.   do
  1219.     location=`check_for_binary $locate_this_bin`
  1220.     if [ $? = 0 ]; then
  1221.       echo "$locate_this_bin:    $location"
  1222.     else
  1223.       echo "$locate_this_bin not found."
  1224.     fi
  1225.   done
  1226. }
  1227.  
  1228. echo_show_variable()
  1229. {
  1230.   for this_var
  1231.   do
  1232.     var=$this_var
  1233.     eval val=\"\${$var+=}\${$var- is unset}\"
  1234.     echo "$var$val"
  1235.   done | grep -v 'is unset$'
  1236. }
  1237.  
  1238. echo_file_location()
  1239. {
  1240.   if [ -f "$2" ]; then
  1241.     echo "$1: $2"
  1242.   else
  1243.     echo "$1 not found."
  1244.   fi
  1245. }
  1246.  
  1247. do_print_setup()
  1248. {
  1249.   echo '==================== binaries found by searching $PATH ==================='
  1250.   echo_locate_binary tex etex pdftex omega mf mpost dialog dvips xdvi kpsewhich mktexpk mktextfm
  1251.   echo
  1252.   echo '=========================== Kpathsea variables ==========================='
  1253.   echo_show_variable TEXMF TEXMFMAIN VARTEXMF
  1254.   echo
  1255.   echo '=============== environment variables (ok if no output here) ============='
  1256.   echo_show_variable $envvars
  1257. }
  1258.  
  1259. show_path()
  1260. {
  1261.   OIFS=$IFS
  1262.   IFS='
  1263. '
  1264.   echo
  1265.   echo '============================= search paths ==============================='
  1266.   for i in $kpsevars
  1267.   do
  1268.     echo $i | awk '{printf("%25s: ", $0)}'
  1269.     kpsewhich -show-path="$i"
  1270.   done
  1271.   IFS=$OIFS
  1272. }
  1273.  
  1274. do_print_all_setup()
  1275. {
  1276.   do_print_setup
  1277.   show_path $kpsevars
  1278. }
  1279.  
  1280. print_setup()
  1281. {
  1282.   do_print_setup | eval $PAGER; fix_pager_more
  1283. }
  1284.  
  1285. all_mt_features='appendonlydir dosnames nomode stripsupplier striptypeface varfonts nomfdrivers'
  1286. get_mt_options()
  1287. {
  1288.   MT_FEATURES=`grep '^:.*MT_FEATURES' $maketex_site_file | sed 's/.*=//;s/}.*//'`
  1289.   for feature in $all_mt_features; do
  1290.     case "$MT_FEATURES" in
  1291.       *${feature}*)
  1292.       eval $feature=on;;
  1293.       *)
  1294.       eval $feature=off;;
  1295.     esac
  1296.   done
  1297. }
  1298.  
  1299. set_mt_options()
  1300. {
  1301.   args="$*"
  1302.   exist_test -f "$texmfcnf" "texmf.cnf file"
  1303.  
  1304.   for feature in $all_mt_features; do
  1305.     eval $feature=off
  1306.   done
  1307.  
  1308.         set x $args; shift
  1309.   reslist=
  1310.   for i
  1311.   do
  1312.     test_in_list "$i" $all_mt_features || continue
  1313.     reslist="$reslist $i"
  1314.   done
  1315.  
  1316.   set x $reslist; shift
  1317.  
  1318.   MT_FEATURES=$1; test $# -ge 1 && shift
  1319.   for i
  1320.   do
  1321.     MT_FEATURES="$MT_FEATURES:$i"
  1322.   done
  1323.   config_replace "$maketex_site_file" '^: ..MT_FEATURES' ": \${MT_FEATURES=$MT_FEATURES}"
  1324. }
  1325.  
  1326. setup_mt_options()
  1327. {
  1328.   get_mt_options
  1329.   run_dialog --checklist '\nSelect options for mktex scripts. Use the spacebar for enable/disable.\n\n' \
  1330.     23 80 7 \
  1331.     appendonlydir "set stick bit on new directories (recommended)" $appendonlydir \
  1332.     dosnames "dpiNNN/NAME.pk instead of NAME.NNNpk" $dosnames \
  1333.     nomode "leave out MODE (e.g. ljfour)" $nomode \
  1334.     stripsupplier "leave out SUPPLIER (e.g. ams)" $stripsupplier \
  1335.     striptypeface "leave out TYPEFACE (e.g. euler)" $striptypeface \
  1336.     varfonts "use \$VARTEXFONTS instead of \$TEXMFMAIN/fonts" $varfonts \
  1337.     nomfdrivers "remove metafont driver after mktex{tfm,pk} run" $nomfdrivers \
  1338.       2>$tmpmenu || return
  1339.   eval set_mt_options `cat $tmpmenu`
  1340. }
  1341.  
  1342. setup_query_mkdir() { yesno "\\n\\nCreate directory $1?\\n\\n" 23 80; }
  1343.  
  1344. setup_mt_vardir()
  1345. {
  1346.   VARTEXFONTS=`kpsewhich -expand-var '$VARTEXFONTS'`
  1347.   run_dialog --inputbox \
  1348.     "Your \$VARTEXFONTS directory currently\\nis set to $VARTEXFONTS.\\n\\nPress RETURN to accept this default or enter\\nthe name of an other directory.\\n\\n" \
  1349.     23 80 2>$tmpmenu || return
  1350.   x=`cat $tmpmenu`
  1351.   test -z "$x" && return
  1352.   test -d "$x" || setup_query_mkdir "$x" || return
  1353.   do_setup_mt_vardir "$x" 2>&1 | tee -a $log
  1354. }
  1355.  
  1356. do_setup_mt_vardir()
  1357. {
  1358.   vardir=$1
  1359.   test -d "$vardir" ||
  1360.     { mkdir "$vardir" && chmod 755 "$vardir"; } || return 1
  1361.   test -d "$vardir/pk" ||
  1362.     { mkdir "$vardir/pk" && chmod 1777 "$vardir/pk"; } || return 1
  1363.   test -d "$vardir/tfm" ||
  1364.     { mkdir "$vardir/tfm" && chmod 1777 "$vardir/tfm"; } || return 1
  1365.   test -d "$vardir/source" ||
  1366.     { mkdir "$vardir/source" && chmod 1777 "$vardir/source"; } || return 1
  1367.  
  1368.   config_replace "$texmfcnf" '^VARTEXFONTS' "VARTEXFONTS  = $vardir"
  1369. }
  1370.  
  1371.  
  1372. setup_mt()
  1373. {
  1374.   while true; do
  1375.     ex=eufm10
  1376.     OIFS=$IFS
  1377.     IFS=': '
  1378.     set x `$TC_MKTEXNAM $ex`
  1379.     IFS=$OIFS
  1380.     pk=$2 tfm=$3
  1381.     run_dialog \
  1382.       --menu "\nSet up target directories for font creation.\n\nExample: current settings for font $ex with default mode\\n         are (tfm resp. pk):\\n\\n $tfm\\n $pk\n\n" \
  1383.       23 80 7 \
  1384.       RETURN 'back to main menu' \
  1385.       FONTRO 'remove global write permissions from standard fonts tree' \
  1386.       FONTRW 'add global write permissions to standard fonts tree' \
  1387.       OPTIONS 'set up options for mktex scripts' \
  1388.       VARDIR 'directory for new fonts (if varfonts option active)' \
  1389.       LOG   'view logfile' \
  1390.       2>$tmpmenu || return
  1391.     ans=`cat $tmpmenu`
  1392.     test -z "$ans" && return
  1393.     case "$ans" in
  1394.       VARDIR)
  1395.         setup_mt_vardir ;;
  1396.       OPTIONS)
  1397.         setup_mt_options ;;
  1398.       FONTRO)
  1399.         get_mt_options
  1400.         VARTEXFONTS=`kpsewhich -expand-var '$VARTEXFONTS'`
  1401.         if test "$varfonts" != on; then
  1402.           run_dialog --msgbox \
  1403.             '\n\n\nPlease enable the varfonts feature (OPTIONS menue) first.' \
  1404.             23 80
  1405.           continue
  1406.         fi
  1407.         if test ! -d "$VARTEXFONTS"; then
  1408.           run_dialog --msgbox \
  1409.             '\n\n\nPlease make sure that the VARTEXFONTS directory exists and try again.' \
  1410.             23 80
  1411.           continue
  1412.         fi
  1413.         if test -z "$VARTEXFONTS"; then
  1414.           run_dialog --msgbox \
  1415.             '\n\n\nPlease set up a non-empty VARTEXFONTS directory (VARDIR menue) first.' \
  1416.             23 80
  1417.           continue
  1418.         fi
  1419.         fonts_ro;;
  1420.       FONTRW)
  1421.         fonts_rw;;
  1422.       LOG)
  1423.         clear; <$log eval $PAGER; fix_pager_more;;
  1424.       RETURN)
  1425.         return ;;
  1426.     esac
  1427.   done
  1428. }
  1429.  
  1430. locate_files()
  1431. {
  1432.   fmtutilcnf=`kpsewhich --format='web2c files' fmtutil.cnf`
  1433.   if test -z "$fmtutilcnf" || test ! -f "$fmtutilcnf"; then
  1434.     echo "Error: kpsewhich cannot find file fmtutil.cnf" >&2
  1435.     exit 1
  1436.   fi
  1437.   modes=`kpsewhich modes.mf`
  1438.   if test -z "$modes" || test ! -f "$modes"; then
  1439.     echo "Error: kpsewhich cannot find file modes.mf" >&2
  1440.     exit 1
  1441.   fi
  1442.   texmfcnf=`kpsewhich texmf.cnf`
  1443.   if test -z "$texmfcnf" || test ! -f "$texmfcnf"; then
  1444.     echo "Error: kpsewhich cannot find file texmf.cnf" >&2
  1445.     exit 1
  1446.   fi
  1447.   maketex_site_file=`kpsewhich --format='web2c files' mktex.cnf`
  1448.   if test -z "$maketex_site_file" || test ! -f "$maketex_site_file"; then
  1449.     echo "Error: kpsewhich cannot find file mktex.cnf" >&2
  1450.     exit 1
  1451.   fi
  1452.   xdvi_app_file=`XDVIINPUTS="$XDVIINPUTS":'$TEXMF/{xdvi,web2c}' kpsewhich -progname=xdvi --format='other text files' XDvi`
  1453.   if test -z "$xdvi_app_file" || test ! -f "$xdvi_app_file"; then
  1454.     echo "Error: kpsewhich cannot find file XDvi" >&2
  1455.     exit 1
  1456.   fi
  1457. }
  1458.  
  1459. # This function rebuilds the html index to the local documentation
  1460. # By Ottavio G. Rizzo
  1461. rebuild_doc()
  1462. {
  1463.   run_dialog --inputbox \
  1464.     "I assume the local TeX documentation is in\\n$doc\\n\\nPress RETURN if this is true or enter the name of the directory.\\n\\n" \
  1465.     23 80 2>$tmpmenu || return
  1466.   x=`cat $tmpmenu`
  1467.   test -z "$x" || doc=$x
  1468.   if  test -d $doc 
  1469.   # Did I get a meaningful directory?
  1470.   then
  1471.      (
  1472.     cd $doc 
  1473.     helpindex=`\ls -l helpindex.html 2>/dev/null | awk '{print $NF}'`
  1474.     case $helpindex in
  1475.       "") helpindex=$doc/helpindex.html;;
  1476.       /*) ;;
  1477.       *)  helpindex=$doc/$helpindex;;
  1478.     esac
  1479.     \mv -f $helpindex $helpindex.BAK
  1480.     # Warn the user it's going to take a while
  1481.     run_dialog --infobox \
  1482.       "This could take some time, please wait." \
  1483.       3 80
  1484.     ./mkhtml > $helpindex  2>> $log
  1485.      )
  1486.   else
  1487.     clear
  1488.     echo -e '\n\n\n\n'
  1489.     echo "$doc doesn't exist!" | tee -a $log
  1490.     echo "Press a key to continue"
  1491.     read foo
  1492.   fi
  1493. }
  1494.  
  1495. config_formats()
  1496. {
  1497.   exist_test -f "$fmtutilcnf" "fmtutil.cnf file"
  1498.  
  1499.   tmpfile=fmt$$
  1500.   sed 's@[%#].*@@; s@^[     ]*@@; /^$/d' $fmtutilcnf | sort > $tmpfile-1
  1501.   
  1502.   clear
  1503.   $EDIT $fmtutilcnf
  1504.  
  1505.   sed 's@[%#].*@@; s@^[         ]*@@; /^$/d' $fmtutilcnf | sort > $tmpfile-2
  1506.   comm -13 $tmpfile-1 $tmpfile-2 > $tmpfile-3
  1507.   for i in `awk '{print $1}' $tmpfile-3`; do
  1508.     fmtutil --byfmt "$i" 2>&1 | tee -a $log
  1509.   done
  1510.   texlinks ${SILENT_TEXLINKS+-s} 2>&1 | tee -a $log
  1511. }
  1512.  
  1513. #------------------ begin: initialisation -----------------------------------
  1514. find_echo
  1515. find_fmt
  1516. find_dialogtype
  1517. check_environ
  1518. require_binary kpsewhich pwd
  1519.  
  1520. TEXMFMAIN_environ=${TEXMFMAIN+yes}
  1521. : ${TC_TEXMFMAIN=`kpsewhich --expand-var='$TEXMFMAIN' | sed 's@^!*@@'`}
  1522.  
  1523. if test -z "$TC_TEXMFMAIN"; then
  1524.   echo "$0: No \$TEXMFMAIN in texmf.cnf file." >&2
  1525.   echo "$0: set TEXMFCNF variable to the directory where teTeX's texmf.cnf file is in." >&2
  1526.   exit 1
  1527. fi
  1528.  
  1529. if test x${TEXMFMAIN_environ} = xyes; then
  1530.   if test ! -f "$TC_TEXMFMAIN/web2c/texmf.cnf"; then
  1531.     echo "Error: file texmf.cnf not found in \`\`$TC_TEXMFMAIN/web2c''."
  1532.     echo "Your environment variable TEXMFMAIN \`\`$TC_TEXMFMAIN'' seems to have the wrong value."
  1533.     exit 1
  1534.   fi
  1535. else
  1536.   if test ! -f "$TC_TEXMFMAIN/web2c/texmf.cnf"; then
  1537.     echo "Error: file texmf.cnf not found in \`\`$TC_TEXMFMAIN/web2c''."
  1538.     echo "TEXMFMAIN \`\`$TC_TEXMFMAIN'' seems to have the wrong value from a texmf.cnf file."
  1539.     exit 1
  1540.   fi
  1541. fi
  1542.  
  1543. : ${TC_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`}
  1544. test -z "$TC_MKTEX_OPT" && TC_MKTEX_OPT="$TC_TEXMFMAIN/web2c/mktex.opt"
  1545.  
  1546. : ${TC_MKTEXDIR=`kpsewhich --format='web2c files' mktexdir`}
  1547. test -z "$TC_MKTEXDIR" && TC_MKTEXDIR="$TC_TEXMFMAIN/web2c/mktexdir"
  1548.  
  1549. : ${TC_MKTEXUPD=`kpsewhich --format='web2c files' mktexupd`}
  1550. test -z "$TC_MKTEXUPD" && TC_MKTEXUPD="$TC_TEXMFMAIN/web2c/mktexupd"
  1551.  
  1552. : ${TC_MKTEXNAM=`kpsewhich --format='web2c files' mktexnam`}
  1553. test -z "$TC_MKTEXNAM" && TC_MKTEXNAM="$TC_TEXMFMAIN/web2c/mktexnam"
  1554.  
  1555. # The texmf tree where we put generated files into. Defaults to system tree:
  1556. : ${TC_VARTEXMF=`kpsewhich -expand-var='$VARTEXMF'`}
  1557. test -z "$TC_VARTEXMF" && TC_VARTEXMF=$TC_TEXMFMAIN
  1558.  
  1559. : ${TC_DFT_XDVI_APP=`XDVIINPUTS="$XDVIINPUTS":'$TEXMF/{xdvi,web2c}' kpsewhich -progname=xdvi --format='other text files' XDvi`}
  1560. test -z "$TC_DFT_XDVI_APP" && TC_DFT_XDVI_APP="$TC_TEXMFMAIN/xdvi/XDvi"
  1561.  
  1562. : ${TC_DFT_MKTEX_CNF=`kpsewhich --format='web2c files' mktex.cnf`}
  1563. test -z "$TC_DFT_MKTEX_CNF" && test -f "$TC_TEXMFMAIN/web2c/mktex.cnf" &&
  1564.   TC_DFT_MKTEX_CNF="$TC_TEXMFMAIN/web2c/mktex.cnf"
  1565.  
  1566. : ${TC_DFT_CONFIG_PS=`kpsewhich -format='dvips config' config.ps`}
  1567. test -z "$TC_DFT_CONFIG_PS" && TC_DFT_CONFIG_PS=$TC_TEXMFMAIN/dvips/config/config.ps
  1568.  
  1569. : ${TC_DFT_LANGUAGE_DAT=`kpsewhich -format=.tex language.dat`}
  1570. test -z "$TC_DFT_LANGUAGE_DAT" && TC_DFT_LANGUAGE_DAT=$TC_TEXMFMAIN/tex/generic/config/language.dat
  1571.  
  1572. : ${TC_DFT_LANGUAGE_DEF=`kpsewhich -format=.tex -progname=etex language.def`}
  1573. test -z "$TC_DFT_LANGUAGE_DEF" && TC_DFT_LANGUAGE_DEF=$TC_TEXMFMAIN/etex/plain/config/language.def
  1574.  
  1575. : ${TC_DFT_CONT_USR=`kpsewhich -format=.tex -progname=context cont-usr.tex`}
  1576. test -z "$TC_DFT_CONT_USR" && TC_DFT_CONT_USR=$TC_TEXMFMAIN/tex/context/config/cont-usr.tex
  1577.  
  1578. : ${TC_DFT_FMTUTIL_CNF=`kpsewhich --format='web2c files' fmtutil.cnf`}
  1579. test -z "$TC_DFT_FMTUTIL_CNF" && TC_DFT_FMTUTIL_CNF=$TC_TEXMFMAIN/web2c/fmtutil.cnf
  1580.  
  1581. # The fallback directory for private scripts and config files.
  1582. : ${TEXMF=`kpsewhich -expand-var '$TEXMF'`}
  1583. : ${DIALOG_TERMINFO=$TC_TEXMFMAIN/texconfig}
  1584. : ${DIALOG_TERM=generic}
  1585.  
  1586. formats=$TC_VARTEXMF/web2c
  1587. bases=$TC_VARTEXMF/web2c
  1588. mems=$TC_VARTEXMF/web2c
  1589. xdvi_app_dir=$TC_VARTEXMF/xdvi
  1590. xdvi_app_file=$xdvi_app_dir/XDvi
  1591. dvips_conf_dir=$TC_VARTEXMF/dvips/config
  1592. pdftex_cnf_dir=$TC_VARTEXMF/pdftex/config
  1593. maketex_site_dir=$TC_VARTEXMF/web2c
  1594. maketex_site_file=$maketex_site_dir/mktex.cnf
  1595. language_dat_dir=$TC_VARTEXMF/tex/generic/config
  1596. language_dat_file=$language_dat_dir/language.dat
  1597. language_def_dir=$TC_VARTEXMF/etex/plain/config
  1598. language_def_file=$language_def_dir/language.def
  1599. cont_usr_dir=$TC_VARTEXMF/tex/context/config
  1600. cont_usr_file=$cont_usr_dir/cont-usr.tex
  1601. fmtutil_cnf_dir=$TC_VARTEXMF/web2c
  1602. fmtutil_cnf_file=$fmtutil_cnf_dir/fmtutil.cnf
  1603. doc=$TC_TEXMFMAIN/doc
  1604.  
  1605. FAQ=$doc/tetex/teTeX-FAQ
  1606.  
  1607. # don't make ls-R files twice, so we check for a rehash option first:
  1608. set x $SAVE_ARGS; shift
  1609. case "$1" in
  1610.   rehash) mktexlsr; exit;;
  1611. esac
  1612.  
  1613. # no rehash option, so make sure we have all necessary ls-R files:
  1614. for dir in $TC_TEXMFMAIN $TC_VARTEXMF; do
  1615.   if [ ! -r $dir/ls-R ]; then
  1616.     require_binary mktexlsr
  1617.     mktexlsr $dir
  1618.   fi
  1619. done
  1620.  
  1621. for i in "$dvips_conf_dir" "$pdftex_cnf_dir" "$formats" "$bases" "$mems" \
  1622.   "$xdvi_app_dir" "$language_dat_dir" "$language_def_dir" "$cont_usr_dir" \
  1623.   "$fmtutil_cnf_dir"; do
  1624.     test -d $i || $TC_MKTEXDIR "$i"
  1625. done
  1626.  
  1627. test -f $maketex_site_file || {
  1628.   if test -n "$TC_DFT_MKTEX_CNF" && test -f "$TC_DFT_MKTEX_CNF"; then
  1629.     cp "$TC_DFT_MKTEX_CNF" $maketex_site_file
  1630.     chmod u+w $maketex_site_file
  1631.   else
  1632.     touch $maketex_site_file
  1633.   fi
  1634.   $TC_MKTEXUPD $maketex_site_dir mktex.cnf
  1635. }
  1636.  
  1637. test -f $xdvi_app_file || {
  1638.   exist_test -f "$TC_DFT_XDVI_APP" "app-default file for xdvi"
  1639.  
  1640.   cp $TC_DFT_XDVI_APP $xdvi_app_file
  1641.   chmod u+w $xdvi_app_file
  1642.   $TC_MKTEXUPD $xdvi_app_dir XDvi
  1643. }
  1644.  
  1645. test -f $dvips_conf_dir/config.ps || {
  1646.   exist_test -f "$TC_DFT_CONFIG_PS" "default config file for dvips (config.ps)"
  1647.  
  1648.   cp $TC_DFT_CONFIG_PS $dvips_conf_dir/config.ps
  1649.   chmod u+w $dvips_conf_dir/config.ps
  1650.   $TC_MKTEXUPD $dvips_conf_dir config.ps
  1651. }
  1652.  
  1653. if test ! -f $language_dat_file; then
  1654.   exist_test -f "$TC_DFT_LANGUAGE_DAT" "language.dat file"
  1655.  
  1656.   cp $TC_DFT_LANGUAGE_DAT $language_dat_file
  1657.   chmod u+w $language_dat_file
  1658.   $TC_MKTEXUPD $language_dat_dir language.dat
  1659. fi
  1660.  
  1661. if test ! -f $language_def_file; then
  1662.   if test -f $TC_DFT_LANGUAGE_DEF; then
  1663.    cp $TC_DFT_LANGUAGE_DEF $language_def_file
  1664.    chmod u+w $language_def_file
  1665.    $TC_MKTEXUPD $language_def_dir language.def
  1666.   fi
  1667. fi
  1668.  
  1669. if test ! -f $cont_usr_file; then
  1670.   if test -f $TC_DFT_CONT_USR; then
  1671.    cp $TC_DFT_CONT_USR $cont_usr_file
  1672.    chmod u+w $cont_usr_file
  1673.    $TC_MKTEXUPD $cont_usr_dir cont-usr.tex 
  1674.   fi
  1675. fi
  1676.  
  1677. if test ! -f $fmtutil_cnf_file; then
  1678.   exist_test -f "$TC_DFT_FMTUTIL_CNF" "fmtutil.cnf file"
  1679.  
  1680.   cp $TC_DFT_FMTUTIL_CNF $fmtutil_cnf_file
  1681.   chmod u+w $fmtutil_cnf_file
  1682.   $TC_MKTEXUPD $fmtutil_cnf_dir fmtutil.cnf
  1683. fi
  1684.  
  1685. locate_files
  1686.  
  1687. test -d $tmpdir && { echo "$tmpdir: directory already exists."; exit; }
  1688. trap 'cd / ; rm -rf $tmpdir; trap '' 0; exit 0' 0 1 2 6 13 15
  1689. mkdir $tmpdir || exit
  1690. cd $tmpdir || exit
  1691. exist_test -d "$tmpdir" "tmpdir directory"
  1692.  
  1693. EDIT=${VISUAL-${EDITOR-$std_editor}}
  1694. PAGER=${PAGER-$std_pager}
  1695.  
  1696. check_for_binary dialog >/dev/null
  1697. dialogok=$?
  1698.  
  1699. # we have called some shellfunctions, so for HP-UX's shell, we need
  1700. # to set the positional parameters this again:
  1701. set x $SAVE_ARGS; shift
  1702. if [ $dialogok != 0 ] && [ $# = 0 ]; then
  1703.         set help
  1704. fi
  1705.  
  1706. #------------------ end: initialisation -----------------------------------
  1707.  
  1708. if test $# -ge 1; then
  1709.   cmd_mode ${1+"$@"}
  1710. fi
  1711.  
  1712. test -f $mems/mpost.mem ||
  1713.   run_config_mp
  1714.  
  1715. test -f $bases/mf.base ||
  1716.   run_config_mf
  1717.  
  1718. fmtutil --missing
  1719. texlinks ${SILENT_TEXLINKS+-s}
  1720.  
  1721. check_terminal
  1722. cat <<eof
  1723.  
  1724. The interactive texconfig utility will be started now. Make sure your
  1725. screen has at least 24 rows and 80 columns. If texconfig crashes now,
  1726. you can still set up your $version system using the batch mode of texconfig.
  1727. Try 'texconfig help' to get a list of options.
  1728.  
  1729. eof
  1730. $echon "Starting dialog utility... "
  1731.  
  1732. # The steps below will clear the screen. Make sure, all error messages
  1733. # can be read. The sleep may be annoying, but I think, it is useful if
  1734. # something goes wrong.
  1735. sleep 4
  1736.  
  1737. echo "TeX-Config. Start on `date`" >$log
  1738.  
  1739. while true ; do
  1740.     #--title "TeX-Config main menu" \
  1741.   run_dialog \
  1742.     --menu "
  1743. Hint: all output of external commands (e.g. tex) is logged into
  1744. a file. You can look at this file using "LOG". If cursor keys make
  1745. trouble, you may have more luck with +/- and TAB.
  1746.  
  1747. " 23 80 12 \
  1748.     "EXIT"    'exit' \
  1749.     "CONF"    'show configuration' \
  1750.     "REHASH"    'rebuild ls-R database' \
  1751.     "FORMATS"    'formats' \
  1752.     "HYPHEN"    'hyphenation' \
  1753.     "MODE"    'default mode (xdvi/dvips/mf)' \
  1754.     "XDVI"    'xdvi configuration' \
  1755.     "DVIPS"    'dvips configuration' \
  1756.     "FONT"    'directories for font creation' \
  1757.     "DOC"    'rebuild html documentation' \
  1758.                 "FAQ"   'frequently asked questions + answers' \
  1759.     "LOG"    'view logfile' \
  1760.     2>$tmpmenu
  1761.  
  1762.   
  1763.   case "`cat $tmpmenu`" in
  1764.   FAQ)    clear; test -f $FAQ && <$FAQ eval $PAGER; fix_pager_more;;
  1765.   CONF)    clear; print_setup;;
  1766.   PREF)    setup_preferences ;;
  1767.   REHASH)    clear; mktexlsr; locate_files ;;
  1768.   FORMATS)    config_formats;;
  1769.   HYPHEN)    config_tex;;
  1770.   MODE)    get_default_mode;;
  1771.   XDVI)    config_xdvi ;;
  1772.   DVIPS)    config_dvips ;;
  1773.   FONT)    setup_mt;;
  1774.   DOC)    rebuild_doc;;
  1775.   LOG)    clear; <$log eval $PAGER; fix_pager_more;;
  1776.   *)    reset 2>/dev/null; stty sane 2>/dev/null;
  1777.     reset 2>/dev/null; clear; exit 0;;
  1778.   esac
  1779. done
  1780.